#include <stdio.h>
#include <math.h>

#define STRING_LENGTH 101

int main(void) {
    int n = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        char string[STRING_LENGTH];
        char target[STRING_LENGTH];
        scanf(" %s %s", string, target);
        char* string_pointer = string;
        // 先干正向查找
        while (*string_pointer != '\0') {
            if (target[0] == *string_pointer) {
                // 开始匹配！
                char* match_string_position = string_pointer;
                char* match_target_position = target;
                while (1) {
                    match_target_position++;
                    if (*match_target_position == '\0') {
                        // 匹配完毕
                        goto yes;
                    }
                    match_string_position++;
                    if (*match_string_position == '\0') {
                        // 回到开头去
                        match_string_position = string;
                    }
                    if (*match_string_position != *match_target_position) {
                        // 不匹配
                        break;
                    }
                }
            }
            string_pointer++;
        }
        // 再干反向查找
        string_pointer = string;
        while (*string_pointer != '\0') {
            if (target[0] == *string_pointer) {
                // 开始匹配！
                char* match_string_position = string_pointer;
                char* match_target_position = target;
                while (1) {
                    match_target_position++;
                    if (*match_target_position == '\0') {
                        // 匹配完毕
                        goto yes;
                    }
                    if (match_string_position == string) {
                        // 跑去末尾
                        char* end_pointer = string;
                        while (*end_pointer != '\0') {
                            end_pointer++;
                        }
                        match_string_position = end_pointer - 1;
                    } else {
                        match_string_position--;
                    }
                    if (*match_string_position != *match_target_position) {
                        // 不匹配
                        break;
                    }
                }
            }
            string_pointer++;
        }
        printf("No\n");
        continue;
        yes:
        printf("Yes\n");
    }
    return 0;
}
